//
//  NestVC.swift
//  swiftDemo
//
//  Created by yaqiang bi on 2017/3/30.
//  Copyright © 2017年 毕小强. All rights reserved.
//
// 嵌套

import UIKit

class NestVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        
        let theAceOfSpades = BlackjackCard(rank: .Ace, suit: .黑桃)
        print(theAceOfSpades.description)
        print(BlackjackCard.Suit.方片.rawValue)
        // Do any additional setup after loading the view.
    }

    struct BlackjackCard {
        enum Suit:Character {
            case 红桃 = "♥️",黑桃 = "♠️",方片 = "♦️",梅花 = "♣️"
        }
        
        enum Rank:Int {
            case Two = 2,Three,Four,Five,Six,Seven,Eight,Nine,Ten
            case Jack,Queen,King,Ace
            
            struct Values {
                let first:Int,second:Int?
            }
            
            
            var values:Values {
                switch self {
                case .Ace:
                    return Values(first: 1, second: 11)
                case .Jack,.Queen,.King:
                    return Values(first: 10, second: nil)
                default:
                    return Values(first: self.rawValue, second: nil)
                }
            }
            
        }
        
        let rank:Rank ,suit:Suit
        var description :String{
            var output = "suit is \(suit.rawValue),"
            output += "Value is \(rank.values.first)"
            if let second = rank.values.second {
                output += " or \(second)"
            }
            return output
        }
        
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
